//
//  HomePopWindow.m
//  Haliaeetus
//
//  Created by junli hou on 2018/5/1.
//  Copyright © 2018年 BMY. All rights reserved.
//

#import "HomePopWindow.h"
#import <UIKit/UIKit.h>
@implementation HomePopWindow
- (id) init
{
    if ( self = [super init] )
    {
         UIWindow *window = [[UIApplication sharedApplication].delegate window];
         self.bgView = [window.rootViewController.view viewWithTag:100];
        if (self.bgView==NULL) {
            self.bgView =[[UIView alloc]init];
            self.bgView.frame=CGRectMake(0, 0, WS_SCREEN_FRAME_WIDTH, WS_SCREEN_FRAME_HEIGHT) ;
            self.bgView.backgroundColor=[UIColor blackColor];
            self.bgView.tag=100;
            self.bgView.alpha=0.6;
            [window.rootViewController.view addSubview:self.bgView];
        }
    }
    
    return self;
}

-(void)initWaitPayView{
   UIWindow *window = [[UIApplication sharedApplication].delegate window];

    self.waitPayView = [window.rootViewController.view viewWithTag:80];
    if (self.waitPayView==NULL) {
        self.waitPayView =[[UIView alloc]init];
        self.waitPayView.frame=CGRectMake((WS_SCREEN_FRAME_WIDTH-340)/2, (WS_SCREEN_FRAME_HEIGHT-320)/2, 340, 320) ;
        self.waitPayView.backgroundColor=[UIColor whiteColor];
        self.waitPayView.layer.masksToBounds = YES;
        self.waitPayView.tag=80;
        
        self.waitPayView.layer.cornerRadius = 2;
        [window.rootViewController.view addSubview:self.waitPayView];
        
        
        self.waitPayLabel = [[UILabel alloc]init];
        self.waitPayLabel.frame = CGRectMake(0,49,340,26);
        self.waitPayLabel.font = [UIFont systemFontOfSize:14];
        self.waitPayLabel.numberOfLines=1;
        self.waitPayLabel.textAlignment=NSTextAlignmentCenter;
        self.waitPayLabel.text=@"手续费";
        self.waitPayLabel.textColor = WS_RGB(68, 69, 60);
        [self.waitPayView addSubview:self.waitPayLabel];
        
        self.waitPayMoneyLabel = [[UILabel alloc]init];
        self.waitPayMoneyLabel.frame = CGRectMake(0,CGRectGetMaxY(self.waitPayLabel.frame),340,30);
        self.waitPayMoneyLabel.font = [UIFont systemFontOfSize:32];
        self.waitPayMoneyLabel.numberOfLines=1;
        self.waitPayMoneyLabel.textAlignment=NSTextAlignmentCenter;
        self.waitPayMoneyLabel.text=@"100元";
        self.waitPayMoneyLabel.textColor = WS_RGB(68, 69, 60);
        [self.waitPayView addSubview:self.waitPayMoneyLabel];
        
        self.waitPayContentLabel = [[UILabel alloc]init];
        self.waitPayContentLabel.frame = CGRectMake(20,CGRectGetMaxY(self.waitPayMoneyLabel.frame)+20,300,35);
        self.waitPayContentLabel.font = [UIFont systemFontOfSize:12];
        self.waitPayContentLabel.numberOfLines=2;
        self.waitPayContentLabel.textAlignment=NSTextAlignmentCenter;
        self.waitPayContentLabel.text=@"您有一笔手续费未支付，未完成支付前，您将无法使用优惠订酒店的功能。";
        self.waitPayContentLabel.textColor = WS_RGB(68, 69, 60);
        [self.waitPayView addSubview:self.waitPayContentLabel];
        
        //登录
        self.payBtn = [[UIButton alloc]init];
        self.payBtn.frame =CGRectMake(50,CGRectGetMaxY(self.waitPayContentLabel.frame)+40,240,40);
        self.payBtn.layer.cornerRadius=2;
        self.payBtn.layer.masksToBounds = YES;
        self.payBtn.backgroundColor = WS_RGB(255, 134, 35);
        self.payBtn.titleLabel.font = [UIFont systemFontOfSize:16];
        [self.payBtn setTitleColor:WS_RGB(255, 255, 255) forState:UIControlStateNormal];
        [self.payBtn setTitle:@"立即支付" forState:UIControlStateNormal];
        [self.payBtn addTarget:self action:@selector(payAction) forControlEvents:UIControlEventTouchUpInside];
        [self.waitPayView addSubview:self.payBtn];
        
    }

    
    
}

-(void)showWaitPayView:(NSDictionary*)payDic{
    [self initWaitPayView];
    self.bgView.hidden=NO;
    self.waitPayView.hidden=NO;
    
}
-(void)hiddenWaitPayView{
//    UIWindow *window = [[UIApplication sharedApplication].delegate window];
//
//    self.bgView = [window viewWithTag:100];
    if (self.waitPayView) {
        self.bgView.hidden=YES;
        self.waitPayView.hidden=YES;
    }
}

-(void)initShareView{
    
    
}
-(void)showShareView:(NSDictionary*)dic{
    
}
-(void)hiddenShareView{
    
}
-(void)payAction{
    [self hiddenWaitPayView];
    
}
@end
